﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using DbLibrary.Abstracts;
using DbLibrary.DataBase;
using Car = DbLibrary.Models.Car;

namespace DbLibrary.Helpers
{
    public class CarCreateHelper : SingletonBase<CarCreateHelper>
    {
        private CarCreateHelper() {}

        public Int32 CreateCar(Car car)
        {
            var rep = new CarRepository();
            if (rep.GetAll().Count(_ => _.Name == car.Name) == 0)
                rep.Save(car);
                
            return car.Id;
        }
    }
}
